00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00034 require_once (PATH_TO_ROOT."messaging/classes/class.messaging_view.inc.php");
00035 require_once (PATH_TO_ROOT."roleplay/classes/class.roleartefacts.inc.php");
00036
00037 class MessagingDetail extends MessagingView {
00038
00044 private $messageID;
00045
00051 private $type;
00052
00058 private $names;
00059
00065 private $namesTitle;
00066
00072 private $message;
00073
00079 private $carbonCopy;
00080
00086 private $bbcode;
00087
00093 private $highlight;
00094
00095
00101 private $date;
00102
00107 public function __construct($messaging) {
00108
00109 parent::__construct($messaging);
00110 }
00111
00117 protected function initView() {
00118 $this->messageID = intval($_GET["messageID"]);
00119 $this->type = $_GET["type"];
00120
00121 if(isset($_GET["highlight"]) && !empty($_GET["highlight"])) {
00122 $this->highlight = Data::toHTML($_GET["highlight"]);
00123 }
00124
00125 $this->message = $this->getMessageDetails();
00126
00127 if(is_null($this->message)) {
00128 Output::errorMessage($this->translate->_("Ungueltige Nachricht!"), 1, false, true);
00129 return false;
00130 }
00131
00132
00133 $this->date = new Zend_Date($this->message->date, Zend_Date::TIMESTAMP);
00134 $this->date = $this->date->get(Zend_Date::DATE_SHORT)." - ".$this->date->get(Zend_Date::TIME_SHORT);
00135
00136 $this->bbcode = new BBCode(false);
00137
00138 if ($this->type == "inbox") {
00139
00140
00141
00142 $this->namesTitle = $this->translate->_("Absender").":";
00143
00144 $this->names = '<a href="'.PATH_TO_ROOT.'user/homepage.php?user='.$this->message->authorID.'">'.Data::toHTML("".$this->message->Vorname." ".$this->message->Nachname, false) ."</a>";
00145
00146 $role = RoleArtefacts::getRoleForItem(PM, (int)$this->messageID);
00147
00148 if ($role) {
00149 $this->names.= " (".$role->getPropertiesLink($role->getName($this->message->gender), $this->translate->_("Rollen-Eigenschaften anzeigen"), true) .")";
00150 }
00151
00152 $this->names.= ' <a href="'.PATH_TO_ROOT.'messaging/buddymanagement.php?resultAction=add&selectedUser%5B%5D='.$this->message->authorID.'" title="'.$this->translate->_("Zur Buddyliste hinzufuegen!").'">'.Output::getIcon("icon_buddy", "Zur Buddyliste hinzufügen") .'</a>';
00153
00154 $this->carbonCopy = $this->getOtherRecipients($this->message);
00155
00156 } elseif ($this->type == "outbox") {
00157
00158
00159 $this->names = $this->messaging->getRecipients($this->message->recipientID, 20, 3);
00160 $this->namesTitle = $this->translate->_("Empfaenger").":";
00161 }
00162 else {
00163 Output::errorMessage($this->translate->_("Ungueltige Parameter!"), 1, false, true);
00164 return false;
00165 }
00166 return true;
00167 }
00168
00174 protected function checkActions() {
00175 if (isset($_GET["messageID"]) && strval(intval($_GET["messageID"])) == $_GET["messageID"] && isset($_GET["type"]) && $_GET["type"] == "inbox") {
00176 $this->messaging->markMessageAsRead($_GET["messageID"]);
00177 }
00178
00179 if (!isset($_GET["messageID"]) ||
00180 !isset($_GET["type"]) ||
00181 strval(intval($_GET["messageID"])) != $_GET["messageID"]) {
00182
00183 Output::errorMessage($this->translate->_("Ungueltige Parameter!"), 1, false, true);
00184 return false;
00185 } else {
00186 if (isset($_GET["action"]) && $_GET["action"] == "archive") {
00187 $this->messaging->archiveMessage($_GET["messageID"], $_GET["type"]);
00188 }
00189 }
00190 return true;
00191 }
00192
00198 public function echoMessageDetail() {
00199 if($this->execution) {
00200
00201 if(is_null($this->message)) {
00202 Output::errorMessage($this->translate->_("Sie haben nicht die Berechtigung, diese Nachricht anzuzeigen."),1 , false, true);
00203 return;
00204 }
00205
00206 $message = $this->bbcode->parse($this->message->message);
00207
00208
00209 if(isset($this->highlight)) {
00210 $words = explode(" ", $this->highlight);
00211 $message = Utilities::highlightWords($message, $words);
00212 }
00213
00214 if($this->type == "inbox") {
00215 $sameNameUsers = $this->messaging->sameNameUsers($this->message->authorID);
00216 }
00217
00218
00219 echo "<form id='messageAction' method='post' action='".PATH_TO_ROOT."messaging/".PATH_TO_MESSAGE_NEW."'>";
00220
00221
00222
00223 if($this->type == "inbox") {
00224
00225 $sender = Data::toHTML($this->message->Nachname.", ".$this->message->Vorname, false) .($sameNameUsers > 0 ? ", $this->message->authorID" : "").";";
00226
00227 echo "<p class='pForm'><input type='hidden' name='Empfaenger' value=\"".$sender."\"/></p>";
00228
00229
00230 if(!empty($this->carbonCopy)) {
00231 $ccPeople = $this->getOtherRecipients($this->message, false);
00232 echo "<p class='pForm'><input type='hidden' name='EmpfaengerAntwortAnAlle' value=\"".$sender.$ccPeople."\"/></p>";
00233 }
00234 }
00235 echo "<p class='pForm'><input type='hidden' name='Betreff' value=\"".Data::toHTML($this->message->subject, false)."\"/></p>
00236 <p class='pForm'><input type='hidden' name='Nachricht' value=\"".Data::toHTML($this->message->message, false)."\"/></p>
00237 <p class='pForm'><input type='hidden' name='Datum' value='".Data::toHTML($this->message->date, false)."'/></p>
00238 <p class='pForm'><input type='hidden' name='Typ' value='".Data::toHTML($this->type, false)."'/></p>
00239 <p class='pForm'><input type='hidden' name='asEmail' value='1'/></p>";
00240
00241
00242 $buttons = array();
00243
00244 if ($this->type == "inbox") {
00245
00246 $buttons[] = "<p class='pForm'><input type='image' src='".PATH_TO_ROOT."images/transparent.gif' class='icon_antworten' name='Reply' value='".$this->translate->_("Antworten")."' title='".$this->translate->_("Antworten")."' /></p>";
00247 if(!empty($this->carbonCopy)) {
00248
00249 $buttons[] = "<p class='pForm'><input type='image' src='".PATH_TO_ROOT."images/transparent.gif' class='icon_antworten_all' name='ReplyAll' value='".$this->translate->_("Allen Antworten")."' title='".$this->translate->_("Allen Antworten")."' /></p>";
00250 }
00251 }
00252
00253 $buttons[] = "<p class='pForm'><input type='image' src='".PATH_TO_ROOT."images/transparent.gif' class='icon_weiterleiten' name='Forward' value='".$this->translate->_("Weiterleiten")."' title='".$this->translate->_("Weiterleiten")."' /></p>";
00254
00255 ($this->type == "inbox") ? $type_ = PATH_TO_MESSAGE_IN : $type_ = PATH_TO_MESSAGE_OUT;
00256 $buttons[] = "<a href='".PATH_TO_ROOT."messaging/".$type_."?action=delete&messageID=".$this->message->ID."'>".Output::getIcon("icon_muell", $this->translate->_("Nachricht loeschen")) ."</a>";
00257
00258 $buttons[] = "<a href='".PATH_TO_ROOT.SCRIPT_NAME."?action=archive&type=".$this->type."&messageID=".$this->message->ID."'>".Output::getIcon("icon_emailarchiv", $this->translate->_("Nachricht archivieren")) ."</a>";
00259
00260 $buttons[] = "<a href='".PATH_TO_ROOT."pdf/build.php?type=pdf&target=pn&direction=".($this->type == "inbox" ? "in" : "out") ."&id=".$this->message->ID."'>".Output::getIcon('icon_pdf', $this->translate->_("Nachricht als PDF exportieren")) ."</a>";
00261
00262
00263 echo "<table class='tableBorder' width='100%'>";
00264 Output::echoTableHead(Output::getIcon('icon_mail', $this->translate->_("Nachricht")) ." ".$this->translate->_("Nachricht"), 4);
00265
00266 echo "<tr>
00267 <td class='tableCellDark' style='width: 15%;' align='right'><strong>".$this->namesTitle."</strong></td>
00268 <td class='tableCellDark'>".$this->names."</td>
00269 </tr>";
00270
00271 if ($this->type == "inbox" && !empty($this->carbonCopy)) {
00272 echo "<tr>
00273 <td class='tableCellDark' align='right'><strong>".$this->translate->_("CC:")."</strong></td>
00274 <td class='tableCellDark'>".$this->carbonCopy."</td>
00275 </tr>";
00276 }
00277
00278 $image = "";
00279 if ($this->message->isArchived == 1) $image = Output::getIcon("icon_emailarchiv", $this->translate->_("Nachricht archiviert"));
00280 echo "<tr>
00281 <td class='tableCellDark' align='right'><strong>".$this->translate->_("Betreff:")."</strong></td>
00282 <td class='tableCellDark'>".$image.$this->message->subject."</td>
00283 </tr>";
00284 echo "<tr>
00285 <td class='tableCellDark' align='right'><strong>".$this->translate->_("Datum:")."</strong></td>
00286 <td class='tableCellDark'>".$this->date."</td>
00287 </tr>";
00288 echo "<tr>
00289 <td colspan='2'><br/></td>
00290 </tr>";
00291 echo "<tr>
00292 <td class='tableCellDark' colspan='2' align='center'><strong>".$this->translate->_("Nachricht")."</strong></td>
00293 </tr>";
00294 echo "<tr>
00295 <td colspan='2'>".$message."</td>
00296 </tr>";
00297 echo "<tr><td colspan='2' align='center'><hr/>".implode(" | ", $buttons) ."</td></tr>";
00298 echo "</table></form>";
00299 }
00300 }
00301
00307 private function getMessageDetails() {
00308
00309 if ($this->type == "inbox") {
00310 $message = $this->db->get_row("SELECT user.Vorname, user.Nachname, user.gender, messaging_inbox.*
00311 FROM user RIGHT JOIN messaging_inbox
00312 ON user.ID = messaging_inbox.authorID
00313 WHERE messaging_inbox.ID ='$this->messageID' AND userID='".$_SESSION["userid"]."'");
00314
00315 if(!isset($this->db->num_rows)) {
00316 return NULL;
00317 }
00318
00319 return $message;
00320 }
00321
00322 if ($this->type == "outbox") {
00323
00324 $message = $this->db->get_row("SELECT messaging_outbox.*
00325 FROM messaging_outbox
00326 WHERE messaging_outbox.ID ='$this->messageID' AND userID='".$_SESSION["userid"]."'");
00327
00328 if(!isset($this->db->num_rows)) {
00329 return NULL;
00330 }
00331
00332 return $message;
00333 }
00334
00335 return NULL;
00336 }
00337
00346 private function getOtherRecipients($message, $format2HTML = true) {
00347
00348 $otherRecipients = $this->db->get_var("SELECT recipientID FROM messaging_outbox WHERE userID='".$message->authorID."' AND subject='".Data::toMysql($message->subject, false) ."' AND message='".Data::toMysql($message->message, false) ."' AND date BETWEEN ".($message->date-1) ." AND ".($message->date+1));
00349
00350 if (substr_count($otherRecipients, ";") > 1) {
00351 $otherRecipients = str_replace(";", ",", $otherRecipients);
00352
00353 if (substr($otherRecipients, -1, 1)==",") $otherRecipients = substr($otherRecipients, 0, -1);
00354 $otherRecipients = $this->db->get_results("SELECT ID, Nachname, Vorname FROM user WHERE ID IN ($otherRecipients) AND ID != '".$this->message->userID."' ORDER BY Nachname, Vorname");
00355 $str = "";
00356 if ($this->db->num_rows) {
00357 if($format2HTML == true) {
00358 foreach($otherRecipients as $recipient) {
00359
00360 if($this->messaging->sameNameUsers($recipient->ID) > 0) {
00361
00362 $str.= "<a href='".PATH_TO_ROOT."user/homepage.php?user=$recipient->ID'>".Data::toHTML($recipient->Nachname.", ".$recipient->Vorname.", ".$recipient->ID, false) ."</a>; ";
00363 }
00364 else {
00365 $str.= "<a href='".PATH_TO_ROOT."user/homepage.php?user=$recipient->ID'>".Data::toHTML($recipient->Nachname.", ".$recipient->Vorname, false) ."</a>; ";
00366 }
00367 }
00368
00369 $otherRecipients = substr($str, 0, -2);
00370 }
00371 else {
00372 foreach($otherRecipients as $recipient) {
00373
00374 if($this->messaging->sameNameUsers($recipient->ID) > 0) {
00375
00376 $str.= Data::toHTML($recipient->Nachname.", ".$recipient->Vorname.", ".$recipient->ID, false).";";
00377 }
00378 else {
00379 $str.= Data::toHTML($recipient->Nachname.", ".$recipient->Vorname, false).";";
00380 }
00381 }
00382
00383 $otherRecipients = $str;
00384 }
00385
00386
00387 } else $otherRecipients = "";
00388 } else {
00389 $otherRecipients = "";
00390 }
00391
00392 return $otherRecipients;
00393 }
00394 }
00395 ?>